<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 平台操作权限
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-select v-model="query.address" placeholder="地址" class="handle-select mr10">
                    <el-option key="1" label="广东省" value="广东省"></el-option>
                    <el-option key="2" label="湖南省" value="湖南省"></el-option>
                </el-select>
                <el-input v-model="query.name" placeholder="权限名" class="handle-input mr10"></el-input>
                <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
            </div>
            <el-table :data="permissionTableData" border class="table" ref="multipleTable" header-cell-class-name="table-header">
                <el-table-column prop="id" label="ID" width="55" align="center" />
                <el-table-column prop="name" label="权限名" align="center" />
                <el-table-column label="权限资源路径" align="center" >
                    <template #default="scope">{{ scope.row.money }}</template>
                </el-table-column>
                <el-table-column label="权限类别" align="center">
                    <template #default="scope">
                        <p v-if="scope.row.type == 0"><el-tag size="small" type="success" effect="dark">目录</el-tag></p>
                        <p v-if="scope.row.type == 1"><el-tag size="small" type="info" effect="dark">菜单</el-tag></p>
                        <p v-if="scope.row.type == 2"><el-tag size="small" type="warning" effect="dark">按钮</el-tag></p>
                    </template>
                </el-table-column>
                <el-table-column label="状态" align="center">
                    <template #default="scope">
                        <el-tag :type="
                                scope.row.status === 1 ? 'success' : scope.row.status === 0 ? 'danger' : '' ">{{ scope.row.strStatus }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="数据状态" align="center">
                    <template #default="scope">
                        <p v-if="scope.row.isDel"><el-tag size="small" type="danger" effect="dark">已删除</el-tag></p>
                        <p v-if="!scope.row.isDel"><el-tag size="small" type="success" effect="dark">正常</el-tag></p>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination background layout="total, prev, pager, next" 
                    :current-page="query.pageIndex"
                    :page-size="query.pageSize" 
                    :total="pageTotal" 
                    @current-change="handlePageChange"></el-pagination>
            </div>
        </div>


    </div>
</template>

<script>
import { ref, reactive } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";

export default {
    name: "permissionTable",
    setup() {
        const query = reactive({
            address: "",
            name: "",
            pageIndex: 1,
            pageSize: 10,
        });
        const permissionTableData = ref([]);
        const pageTotal = ref(0);
        // 获取表格数据
        const getData = () => {
                permissionTableData.value = null;
                pageTotal.value = 50;
        };
        getData();
        // 查询操作
        const handleSearch = () => {
            query.pageIndex = 1;
            getData();
        };
        // 分页导航
        const handlePageChange = (val) => {
            query.pageIndex = val;
            getData();
        };
        return {
            query,
            permissionTableData,
            pageTotal,
            handleSearch,
            handlePageChange,
        };
    },
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>
